TK!2
=v
#1
:n

:s
b
:c
*** The Cubic Equation Solver ***
#3
:n
x1
:v
-3.201472338219241
:s
o
:c
1st real root
#4
:n
x2
:v
2.746568246995718
:s
o
:c
2nd real root
#5
:n
x3
:v
.4549040912235239
:s
o
:c
3rd real root
#6
:n
re
:s
b
:c
real part of complex root
#7
:n
im
:s
b
:c
imaginary part of complex root
#9
:n
a
:v
3
:s
i
:c
parameters of general form
#10
:n
b
:v
0
:s
i
:c
of the cubic equation
#11
:n
c
:v
-27
:s
i
:c
a*x^3 + b*x^2 + c*x + d = 0
#12
:n
d
:v
12
:s
i
#14
:n
r
:v
0
:s
o
:c
parameters of
#15
:n
s
:v
-9
:s
o
:c
normal form
#16
:n
t
:v
4
:s
o
:c
x^3 + r*x^2 + s*x + t = 0
#18
:n
p
:v
-9
:s
o
:c
parameters of reduced form
#19
:n
q
:v
4
:s
o
:c
y^3 + p*y + q = 0 ,  y=x-r/3
#21
:n
R
:v
-23
:s
o
:c
radicand
#22
:n
w
:v
1.732050807568877
:s
o
:c
Vieta    )
#23
:n
phi
:v
1.175696659508507
:s
o
:c
 -"-     )  auxiliary
#24
:n
u
:s
b
:c
Cardano  )  parameters
#25
:n
v
:s
b
:c
 - " -   )
=u
=l
=f
=r
#1
:r
r = b/a                       " Note: This model solves directly any cubic
#2
:r
s = c/a                       " equation in general form (given a,b,c,d),
#3
:r
t = d/a                       " normal form (given r,s,t) or reduced form
#4
:r
p = s - r^2/3                 " (given p,q).  Vieta's trigonometric substi-
#5
:r
q = 2*r^3/27 - r*s/3 + t      " tutions or Cardano's formulas are used for
#6
:r
R = (p/3)^3 + (q/2)^2         " evaluating three real roots or one real and
#7
:r
                              " two conjugate complex roots respectively.
:s
C
#8
:r
if R<=0 then w^2 = abs(p/3)   " " " " " " " " " " " " " " " " " " " " " " " "
#9
:r
        cos(phi) = min((q/2)/w^3,1)         "    three
#10
:r
        x1 + r/3 = -2*w*cos(phi/3)          "    real
#11
:r
        x2 + r/3 = 2*w*cos((pi()-phi)/3)    "    roots
#12
:r
        x3 + r/3 = 2*w*cos((pi()+phi)/3)    "
#14
:r
if R>0 then  u^3 = -q/2 + sqrt(R)           "
#15
:r
              -q = u^3 + v^3                "    one real
#16
:r
           u + v = x1 + r/3                 "    and two
#17
:r
if R>0 then   re = -(x1+r)/2                "    complex
#18
:r
              im = (u-v)*sqrt(3/4)          "    roots
#20
:r
r = given('p,'q,0,r)      " default r=0 when p or q is given
=p
=t
=n
=g
#1
:c
.000001
:i
10
:v
Yes
:l
60
:f
66
:m
0
:w
80
:b
Yes
:a
Yes
:r
Yes
:h
No
:t
1
:n
Yes
:d
LPT1
%Tv,f,0,5,0,1,0
